package com.itwn.web;

import com.itwn.entity.User;
import com.itwn.service.UserService;
import com.itwn.util.SpringUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/list")
public class ListServlet extends BaseServlet{
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        UserService userService = (UserService) SpringUtil.getBean("userServiceImpl");
        List<User> users = userService.queryAll();
        req.setAttribute("users",users);
        req.getRequestDispatcher(req.getContextPath()+"/jsp/list.jsp").forward(req,resp);
    }
}
